﻿@model QuanLyGiaoVuUI.Models.LopMonHoc.CapNhatLopMonHocViewModel
@{
    Layout = null;
}


@{
    int i = 0;
    var count = 0;
    <table class="data display datatable">
        <thead>
            <tr>
                <th class="sorting" style="width: 50px;">STT</th>
                <th class="sorting" style="width: 100px;">Mã Lớp</th>
                <th class="sorting" style="width: 200px;">Tên Môn Học</th>
                <th class="sorting" style="width: 100px;">Loại Lớp</th>
                <th class="sorting" style="width: 100px;">SS.Tối Đa</th>
            </tr>
        </thead>

        @foreach (var lopmonhoc in Model.DanhSachLopMonHoc)
        {
            string temp = "XacNhanGV" + i;
            string temp2 = "GhiChuGV" + i;
            <tr class="gradeA @(++count % 2 == 0 ? "even" : "odd")">
                <td class="odd gradeX">@i</td>
                <td class="odd gradeX">@lopmonhoc.MaLopMonHoc</td>
                <td class="odd gradeX">@lopmonhoc.MonHoc.TenMonHoc</td>
                <td class="odd gradeX">@(lopmonhoc.LoaiLop == 0 ? "Lý thuyết" : "Thực Hành")</td>
                <td class="odd gradeX">@lopmonhoc.SiSoToiDa</td>
            </tr>
            i++;
        }
    </table>
}
<br />
<br />
<br />
@{Html.EnableClientValidation();}
@{using (Ajax.BeginForm("DeNghiMoLop", "GiangVienClient", new AjaxOptions
  {
      HttpMethod = "POST",
      OnSuccess = ""
  }))
  {
    @Html.HiddenFor(model => model.MaGiangVien1);
    <input type="hidden" name="MaLopMonHoc" value="1" />
    <table class="form">
        <tr>
            @Html.HiddenFor(model => model.LopMonHocId)
        </tr>
        <tr>
            <th>
                <div class="editor-label">
                    @Html.LabelFor(model => model.MaMonHoc)
                </div>
            </th>
            <td>
                <div class="editor-field">
                    @Html.DropDownList("MaMonHoc", new SelectList(Model.DanhSachMonHoc, "ID", "MaVaTenMonHoc"))
                    @Html.ValidationMessageFor(model => model.MaMonHoc)
                </div>
            </td>
        </tr>
        <tr>
            <th>
                <div class="editor-label">
                    @Html.LabelFor(model => model.LopSinhVienId)
                </div>
            </th>
            <td>
                <div class="editor-field">
                    @Html.DropDownList("LopSinhVienId", new SelectList(Model.DanhSachLopSinhVien, "MaLop", "TenLop", Model.DanhSachLopSinhVien.ToList().Find(obj => obj.MaLop == Model.LopSinhVienId)))
                    @Html.ValidationMessageFor(model => model.LopSinhVienId)
                </div>
            </td>
        </tr>
        <tr>
            <th>
                <div class="editor-label">
                    @Html.LabelFor(model => model.SiSoToiDa)
                </div>
            </th>
            <td>
                <div class="editor-field">
                    @Html.EditorFor(model => model.SiSoToiDa)
                    @Html.ValidationMessageFor(model => model.SiSoToiDa)
                </div>
            </td>
        </tr>
        <tr>
            <th>
                <div class="editor-label">
                    @Html.LabelFor(model => model.LoaiLop)
                </div>
            </th>
            <td>
                <div class="editor-field">
                    <select name="LoaiLop" id="LoaiLop">
                        <option value="0">Lý Thuyết</option>
                        <option value="1">Thực Hành</option>
                    </select>
                </div>
            </td>
        </tr>
    </table>
    <input type="submit" value="Đề nghị" />
  }
}

<div id="selectMonHocDialog">
</div>
<script>
    $(document).ready(function () {
        $("#selectMonHocDialog").load("/LopMonHoc/LayDanhSachMonHoc?maGiangVien=" + "@Model.MaGiangVien1.ToString()");
        $("#selectMonHocDialog").dialog({
            autoOpen: false, modal: true, width: 800, height: "auto", buttons: {
                "Chọn": function () {
                    $("#MaMonHoc").val($("#selectedMonHocId").val());
                    $("#TenMonHoc").html($("#maVaTenMonHoc").val());
                    $("#dsMonHocDialog").dialog("close");
                }
            }
        });

        $("#TenMonHoc").click(0, function () {
            $("#selectMonHocDialog").dialog("open");
        });
    });
</script>
